﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Avatar.Model;
using AvatarHelper;
using System.Web.Caching;

public partial class UserControl_Default_Industry : System.Web.UI.UserControl
{
    List<Industry> _industrys;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Cache["industryIndex"] == null)
            {
                using (var _adc = DBHelper.GetDataContext())
                {
                    _industrys = _adc.Industry.OrderByDescending(i => i.Job.Count()).Take(17).ToList();
                    Cache.Insert("industryIndex", _industrys, null, DateTime.Now.AddMinutes(60), TimeSpan.Zero);
                }
            }
        }
        _industrys = (List<Industry>)Cache["industryIndex"];
        repeater_Industry.DataSource = _industrys;
        repeater_Industry.DataBind();
    }
}
